package cn.stylefeng.guns.modular.wx;

import cn.stylefeng.guns.modular.course.entity.Category;
import cn.stylefeng.guns.modular.course.entity.Course;
import cn.stylefeng.guns.modular.course.entity.CourseVideo;
import cn.stylefeng.guns.modular.course.service.CategoryService;
import cn.stylefeng.guns.modular.course.service.CourseService;
import cn.stylefeng.guns.modular.course.service.CourseVideoService;
import cn.stylefeng.guns.modular.yy.entity.Banner;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import java.math.BigDecimal;
import java.util.List;

@RequestMapping(value = "web/course")
@Controller
public class WxCourseController {
    @Autowired
    CategoryService categoryService;

    @Autowired
    CourseService courseService;

    @Autowired
    CourseVideoService courseVideoService;


    private String PREFIX = "/web";

    @RequestMapping("course")
    public String index(Model model,int id) {

        Course course=courseService.getById(id);
        Category category=categoryService.getById(course.getCategoryId());
        //课程视频
        CourseVideo courseVideo=new CourseVideo();
        courseVideo.setCourseId(id);
        List<CourseVideo> courseVideoList=courseVideoService.findListBySpec(courseVideo);
        model.addAttribute("course",course);
        model.addAttribute("category",category);
        model.addAttribute("videoList",courseVideoList);
        return PREFIX + "/course/course.html";
    }



}
